package com.whq.mvc.base.enumtype;

/**
 * 月份枚举
 */
public enum MonthEnum {
    MONTH_1(1, "一月"), MONTH_2(2, "二月"), MONTH_3(3, "三月"), MONTH_4(4, "四月"),
    MONTH_5(5, "五月"), MONTH_6(6, "六月"), MONTH_7(7, "七月"), MONTH_8(8, "八月"),
    MONTH_9(9, "九月"), MONTH_10(10, "十月"), MONTH_11(11, "十一月"), MONTH_12(12, "十二月");

    private Integer code;
    private String value;

    MonthEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public static MonthEnum from(Integer code) {
        switch (code) {
            case 1:
                return MONTH_1;
            case 2:
                return MONTH_2;
            case 3:
                return MONTH_3;
            case 4:
                return MONTH_4;
            case 5:
                return MONTH_5;
            case 6:
                return MONTH_6;
            case 7:
                return MONTH_7;
            case 8:
                return MONTH_8;
            case 9:
                return MONTH_9;
            case 10:
                return MONTH_10;
            case 11:
                return MONTH_11;
            case 12:
                return MONTH_12;
            default:
                throw new RuntimeException("code错误");
        }
    }
}
